/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Heinz Hernandez
 */
@Entity
@Table(name = "owner")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Owner.findAll", query = "SELECT o FROM Owner o"),
    @NamedQuery(name = "Owner.findByOwnId", query = "SELECT o FROM Owner o WHERE o.ownId = :ownId"),
    @NamedQuery(name = "Owner.findByOwnAdd", query = "SELECT o FROM Owner o WHERE o.ownAdd = :ownAdd"),
    @NamedQuery(name = "Owner.findByOwnMobile", query = "SELECT o FROM Owner o WHERE o.ownMobile = :ownMobile")})
public class Owner implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "OWN_ID")
    private Long ownId;
    @Basic(optional = false)
    @Column(name = "OWN_ADD")
    private String ownAdd;
    @Basic(optional = false)
    @Column(name = "OWN_MOBILE")
    private String ownMobile;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ownId")
    private List<Pet> petList;
    @JoinColumn(name = "PER_ID", referencedColumnName = "PER_ID")
    @ManyToOne
    private Person perId;

    public Owner() {
    }

    public Owner(Long ownId) {
        this.ownId = ownId;
    }

    public Owner(Long ownId, String ownAdd, String ownMobile) {
        this.ownId = ownId;
        this.ownAdd = ownAdd;
        this.ownMobile = ownMobile;
    }

    public Long getOwnId() {
        return ownId;
    }

    public void setOwnId(Long ownId) {
        this.ownId = ownId;
    }

    public String getOwnAdd() {
        return ownAdd;
    }

    public void setOwnAdd(String ownAdd) {
        this.ownAdd = ownAdd;
    }

    public String getOwnMobile() {
        return ownMobile;
    }

    public void setOwnMobile(String ownMobile) {
        this.ownMobile = ownMobile;
    }

    @XmlTransient
    public List<Pet> getPetList() {
        return petList;
    }

    public void setPetList(List<Pet> petList) {
        this.petList = petList;
    }

    public Person getPerId() {
        return perId;
    }

    public void setPerId(Person perId) {
        this.perId = perId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ownId != null ? ownId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Owner)) {
            return false;
        }
        Owner other = (Owner) object;
        if ((this.ownId == null && other.ownId != null) || (this.ownId != null && !this.ownId.equals(other.ownId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Owner[ ownId=" + ownId + " ]";
    }
    
}
